<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

# Author    :  ELIZAR M. FLORES
# Copyright : Copyright? what do you mean copyright? The best thing in programming is OPEN SOURCE. So go ahead dig in.
#             If you know what you are doing, MODIFY and IMPROVE.
#             If you dont know what you are doing, READ and ASK.
#             If you are a hacker, Go somewhere else. 
#             If you are rich, Go ahead... DONATE!


class Model_groups extends CI_Model{
    
    public function get_group_members($groupId,$order='ORDER BY date_added DESC',$limit='0,10')
    {
        $query = 'SELECT CONCAT(first_name," ",last_name) AS name, member.member_id, photo, date_added FROM member 
                                                         JOIN group_assignment ON member.member_id=group_assignment.member_id
                                                         WHERE group_assignment.group_id =:id';
        $params = array('id'=>$groupId);
        $group = new QUERY();
        
        $result = $group->run($query, $params)->fetchAll(pdo::FETCH_ASSOC);
        return $result;    
    }
    
    public function get_group_info($group_id)
    {
      $key   = array('group_id'=>$group_id);
      $group = new QUERY(array('TABLE'=>'groups','KEY'=>$key));
      $result = $group->fetchRow();
      return $result;
    }
    
}
